//根据类型判断状态
function typeOfState(data, index, type) {
  switch (key) {
    case value:
      break;

    default:
      break;
  }
}
//处理多数据
function dealMdata(this_data, max_data, min_data, zcw_data, zsw_num, index2) {
  let end_araay = [];
  let araay1 = [this_data, max_data, min_data, zcw_data, zsw_num];
  for (let index = 0; index < 5; index++) {
    let item_array = [
      araay1[index][index2] - araay1[index][index2 - 1] > 0,
      araay1[index][index2] - araay1[index][index2 - 1] < 0,
      araay1[index][index2] != araay1[index][index2 - 1],
      araay1[index][index2] == araay1[index][index2 - 1],
    ];
    end_araay.push(item_array);
  }
  return end_araay;
}

function appraiseNum(zcw3, this_data, time, zsw, min_data, max_data) {
  let array1 = [];
  zcw3.forEach((item, index) => {
    let this_data_type = this_data[index] - this_data[index - 1];
    this_data_type = this_data_type > 0;
    if (this_data_type) {
      if (zcw3[index - 1] == zcw3[index - 2]) {
        if (zcw3[index] != zcw3[index - 1]) {
          if (this_data[index - 1] - this_data[index - 2] > 0) {
            if (this_data[index] > item) {
              if (
                item - zcw3[index - 1] > 0 &&
                min_data[index] != min_data[index - 1]
              ) {
                // array1.push({
                //   name: "开始下跌",
                //   index: index,
                //   time: time[index],
                //   num: item,
                // });
              }
            }
          }
        }
      }
    } else {
      if (zcw3[index - 1] == zcw3[index - 2]) {
        if (
          zcw3[index] != zcw3[index - 1] &&
          min_data[index] == min_data[index - 1] &&
          this_data[index] - this_data[index - 1] < 0
        ) {
          array1.push({
            name: "开始触底",
            index: index,
            time: time[index],
            num: item,
          });
        }
      }
    }
  });
  return array1;
}

//初始化数据,止跌的买卖推荐
export const initZhiDie = (dataLoss) => {
  dataLoss = JSON.parse(JSON.stringify(dataLoss));

  //近30日支撑位
  let zhidie = dataLoss.deal_data2.ji_zhidie.reverse();
  let zhidie_array = [];
  let zdf_min = dataLoss.deal_data2.zdf_min_array;
  let zdf_max = dataLoss.deal_data2.zdf_max_array;
  let this_num = dataLoss.this_data_num;
  //评价值

  zhidie.forEach((item, index) => {
    if (index > 0) {
      //判断是不是等于
      if (zhidie[index - 1] == zhidie[index - 2]) {
        if (zdf_min[index - 1] == zdf_min[index - 2]) {
          if (zhidie[index] - zhidie[index - 1] > 0) {
            if (zdf_min[index] - zdf_min[index - 1] < 0) {
              if (this_num[index - 1] - this_num[index - 2] < 0) {
                zhidie_array.push({
                  name: "开始买入",
                  index: index,
                  time: dataLoss.this_data[index],
                  num: zhidie[index],
                });
              }
            }
          }

          if (
            this_num[index] - this_num[index - 1] > 0 &&
            zdf_min[index - 2] - zdf_min[index - 3] > 0 &&
            zdf_min[index - 1] == zdf_min[index - 2] &&
            zdf_min[index] == zdf_min[index - 1] &&
            zhidie[index] == zhidie[index - 1] &&
            zhidie[index - 2] - zhidie[index - 3] > 0 &&
            zdf_max[index] == zdf_max[index - 1]
          ) {
            zhidie_array.push({
              name: "开始下跌",
              index: index,
              time: dataLoss.this_data[index],
              num: zhidie[index],
              num1: 1,
            });
          }
        }
      } else {
        if (
          this_num[index - 1] - this_num[index - 2] < 0 &&
          this_num[index] - this_num[index - 1] > 0 &&
          this_num[index - 2] - this_num[index - 3] > 0 &&
          zdf_min[index - 2] == zdf_min[index - 3] &&
          zdf_min[index - 1] != zdf_min[index - 2] &&
          zdf_min[index] == zdf_min[index - 1] &&
          zhidie[index] == zhidie[index - 1] &&
          zhidie[index - 1] != zhidie[index - 2] &&
          zdf_max[index] == zdf_max[index - 1] &&
          zdf_max[index - 1] == zdf_max[index - 2] &&
          zdf_max[index - 2] == zdf_max[index - 3]
        ) {
          let type1 =
            zhidie[index - 1] - zhidie[index - 2] < 0 &&
            zdf_min[index - 1] - zdf_min[index - 2] > 0;
          let type2 =
            zhidie[index - 1] - zhidie[index - 2] > 0 &&
            zdf_min[index - 1] - zdf_min[index - 2] < 0;
          if (type1 || type2) {
            zhidie_array.push({
              name: "开始下跌",
              index: index,
              time: dataLoss.this_data[index],
              num: zhidie[index],
              num1: 1,
            });
          }
        }
        //卖出
        if (
          this_num[index - 1] - this_num[index - 2] > 0 &&
          this_num[index - 2] - this_num[index - 3] > 0
        ) {
        } else {
          if (
            this_num[index] - this_num[index - 1] > 0 &&
            zdf_min[index - 2] == zdf_min[index - 3] &&
            zdf_min[index] == zdf_min[index - 1] &&
            zdf_min[index - 1] == zdf_min[index - 2] &&
            zhidie[index] == zhidie[index - 1] &&
            zhidie[index - 2] == zhidie[index - 3] &&
            zhidie[index - 1] > zhidie[index - 2] &&
            zdf_max[index] == zdf_max[index - 1]
          ) {
            zhidie_array.push({
              name: "开始下跌",
              index: index,
              time: dataLoss.this_data[index],
              num: zhidie[index],
              num1: 1,
            });
          }
        }
      }
    }
  });

  return {
    zhidie_array: {
      name: "止跌买入卖出",
      num: zhidie_array,
    },
  };
};
export default {
  initZhiDie,
};
